package com.bootdo.clouddo.controller.baidu;


import com.bootdo.clouddo.service.baidu.IImageService;
import com.bootdo.clouddo.utils.R;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/baidu/image")
public class ImageController {


    @Autowired
    private IImageService imageService;

    @GetMapping("/find")
    public R find(@RequestParam(defaultValue="1")Integer page, @RequestParam(defaultValue="12")Integer size) {
        PageHelper.startPage(page, size);
        return R.data(new PageInfo<>(imageService.find(page, size)));
    }
    
    @RequestMapping("/delete/{id}")
    public R delete(@PathVariable String id) {
    	try {
    		imageService.delete(id);
			return R.ok();
		} catch (Exception e) {
			e.getSuppressed();
		}
    	return R.error();
    }
}
